package com.nuanshui.heatedloan.socket.service;

import com.nuanshui.heatedloan.socket.ProtoMsg;
import com.nuanshui.heatedloan.socket.server.TCPServer;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

/**
 * @author zss
 * @date 2017/6/7
 * @description
 */
@Service(value ="tcpServerService")
public class TcpServerServiceImpl implements TcpServerService,InitializingBean {

    private Logger logger = LoggerFactory.getLogger(TcpServerServiceImpl.class);


    @Override
    public void invokeSend(ProtoMsg.Msg.Builder builder, ChannelHandlerContext chct) {
        logger.info("***************************开始调用TCPServer中send方法***************************");
        TCPServer.getSingletonInstance().send(builder,chct);
        logger.info("***************************调用成功TCPServer中send方法***************************");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.info("***************************TCPServer开始启动***************************");
        TCPServer.getSingletonInstance().run();
        logger.info("***************************TCPServer启动成功***************************");
    }
}
